﻿@model Lottery.Models.Home.UserLogModel
@{
    ViewBag.Title = "会员系统 - 用户记录";
    Model.Caption = "用户记录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.AppendLine(string.Format("var data={{Total:{0},", Model.List.Count));
    sb.AppendLine("Rows:[");
    for (int i = 0; i < Model.List.Count; i++)
    {
        var item = Model.List[i];
        if(i == 0)
        {
            sb.Append("{");
        }
        else
        {
            sb.Append(",{");
        }
        sb.Append(string.Format("ID:'{0}',", item.Id));
        sb.Append(string.Format("Operator:'{0}',", item.Operator));
        sb.Append(string.Format("Datetime:'{0}',", item.Datetime.ToString()));
        sb.Append(string.Format("Action:'{0}',", item.Action));
        sb.Append(string.Format("Ip:'{0}'", item.Ip));
        sb.Append("}");
    }
    sb.AppendLine("]};");
    string data = sb.ToString();
}
<script type="text/javascript">
    @Html.Raw(data)
    var grid;
    $(function () {

        grid = $("#maingrid").ligerGrid({
            columns: [
                { display: '操作人', name: 'Operator',width:140},
                { display: '操作时间', name: 'Datetime',width:180},
                { display: '行为', name: 'Action',width:180},
                { display: '操作IP', name: 'Ip',width:100}],
                isScroll: false, data: data,pageSize:30,alternatingRow:true
        }
        );
        resetGridHeight(grid);
            $(window).resize(function () {
                resetGridHeight(grid);
            });
    });</script>

 <div id="maingrid"></div>